<?php

require_once 'sdkAmazon/sdk.class.php';
class system_amazondb{
    /**
     *
     * @var AmazonSDB
     */
    public $engine = null;

    public function __construct() {
        $this->engine = new AmazonSDB();
        $this->engine->set_region(AmazonSDB::REGION_EU_W1);        
    }
    public function test($data){
        $this->insert("likewinn_admin_user", $data);        
        die;
        $domain = $this->engine->get_domain_list();
        echo "<pre>";print_r($domain);die;
    }

    public function insert($tableName, $data){      
        $data1 = serialize(array(
			'Item_01' => array(
				'Category'    => 'Clothes',
				'Subcategory' => 'Sweater',
				'Name'        => 'Cathair Sweater',
				'Color'       => 'Siamese',
				'Size'        => array('Small', 'Medium', 'Large')
			),
			'Item_02' => array(
				'Category'    => 'Clothes',
				'Subcategory' => 'Pants',
				'Name'        => 'Designer Jeans',
				'Color'       => 'Paisley Acid Wash',
				'Size'        => array('30x32', '32x32', '32x34')
			)			
		));
//        $search = array('"',"'");
//        $replace = array("");
//        $data1 = str_replace($search, $replace, $data1);        
        
        echo $data1;
        echo "<hr/>";
        
        $add = $this->engine->batch_put_attributes($tableName, array(
			time() => array(
				'Category'    => 'Clothes',
				'Subcategory' => 'Sweater',
				'Name'        => 'Cathair Sweater',
				'Color'       => 'Siamese',
				'Size'        => $data1 . $data1 . $data1
			)));
//        print_r($data);die;
        print_r($add);
        echo $add->status;
        
//        $add = $this->engine->batch_put_attributes($tableName, array("Item_01" => $data));
        echo $add->isOK();
    }
}
